<?php

class Sondage_GparticipantsController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    	
    	parent::init();
    	if (Zend_Auth::getInstance()->hasIdentity()) {
    		//echo "already logged in as: " ;//. Zend_Auth::getInstance()->getIdentity();
    		$identity=Zend_Auth::getInstance()->getIdentity();

    	}else{
    		$this->_helper->redirector('login','authentification','sondage');
    	}
    	
    	
    }

    public function indexAction()
    {
        // action body
    }

    public function inscriptionAction()
    {
        // action body
        
    	$inscriptionform = new Application_Form_Inscription();
    	$this->view->form = $inscriptionform;
    	
    	if ($this->_request->isPost()) {
    		$formData = $this->_request->getPost();
    		if ($inscriptionform->isValid($formData)) {
    			$formation = new Application_Model_DbTable_Sondagepersonne();
    			$row = $formation->createRow();
    	
    			$row->nom = $inscriptionform->getValue('nom');
    			$row->prenom = $inscriptionform->getValue('prenom');
    			$row->adresse = $inscriptionform->getValue('adresse');
    			$row->email = $inscriptionform->getValue('email');
    			$row->login = $inscriptionform->getValue('login');
    			$row->password = $inscriptionform->getValue('password');
    			$row->telephone = $inscriptionform->getValue('telephone');
    			$row->role = 'participant';
    			
    			$result = $row->save();
    			//	$inscriptionform->reset();
    	
    			$this->_helper->redirector("index");
    		}
    	}
    	
    	
    }

    public function addadminAction()
    {
        // action body 	
    }

    public function authentificationAction()
    {
        // action body
    }

    public function logoutAction()
    {
       
    }


}









